<?php

class User_model extends CI_Model
{

    public function __construct()
    {
        $this->load->database();
    }

    public function getAll()
    {
        $query = $this->db->get("user");
        return $query->result_array();
    }

    public function getOneUserByUsername($username = NULL)
    {
        if ($username != NULL) {
            $query = $this->db->get_where("user", array(
                "username" => $username
            ));
        }
        return $query->row_array();
    }

    public function getOneUserById($id = NULL)
    {
        if ($id != NULL) {
            $query = $this->db->get_where("user", array(
                "id" => $id
            ));
        }
        return $query->row_array();
    }
}

?>